<template>
	<view>
		<view class="u-flex user-box  u-p-t-30 u-p-l-30 u-p-r-20 u-p-b-30" :class="{avatarBody:isAndroid}">
			<view class="u-m-r-10" avatar-body>
				<oss-upload></oss-upload>
			</view>
			<view class="u-flx-1" :class="{nameBody:isAndroid}">
				<view class="u-font-18 u-p-b-20">{{vuex_user.name}}</view>
				<view class="u-font-14 u-tips-color">邮箱:{{vuex_user.email}}</view>
			</view>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="setting" title="个人信息" @click="toBaseInfo"></u-cell-item>	
			</u-cell-group>
		</view>
		
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="rmb-circle" title="我的订单"></u-cell-item>
				<u-cell-item icon="star" title="我的收藏"></u-cell-item>
				<u-cell-item icon="m" title="收货地址"></u-cell-item>
			</u-cell-group>
		</view>
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="reload" title="退出登录" @click='logout()'></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				pic:'https://uviewui.com/common/logo.png',
				show:true,
				isAndroid:false
			}
		},
		onLoad() {
			// 如果没有token,跳转到登录页面
			/* 
			因为经常会使用到 所以把这个封装起来 每用到就调用即可
			const token = this.vuex_token
			if(!token){
				setTimeout(() => {
					this.$u.toast('请登录')
					this.$u.route({
						type:'redire',
						url: 'pages/auth/login',
					})
			}, 15000)
			}	 */		
		if(!this.$u.utils.isLogin()) return
		// console.log(121365)
		  if(this.$u.utils.isAndroid()){
				// this.$u.toast('安卓')
				this.isAndroid = true
			}else{
				// this.$u.toast('其他')
			}
		},
		methods: {
			toBaseInfo(){
				this.$u.route({
					url:'pages/center/baseInfo'
				})
			},
			// 退出登录
			async	logout(){
				// 请求api 退出登录
				await this.$u.api.authLogout()
				this.$u.toast('退出成功')
				setTimeout(() => {
					// 清除缓存token和用户信息
					this.$u.vuex('vuex_token',null)
					this.$u.vuex('vuex_user',{})
					
				},1500)
				//关闭所有页面 跳转首页
				this.$u.route({
					type:'reLaunch',
					url:'pages/index/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #ededed;
	}
	
	.camera{
		width: 54px;
		height: 44px;
		
		&:active{
			background-color: #ededed;
		}
	}
	.user-box{
		background-color: #fff;
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 40rpx;
	}
	
	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}
	
	.title {
		font-size: 28rpx;
		color: $u-content-color;
	}
	
	.link-demo {
		margin-top: 80rpx;
	}
	.avatar-body{
		height: 70rpx;
		width: 70rpx;
	}
	.avatarBody{
		padding: 30rpx 30rpx 70rpx!important;
	}
	.nameBody{
		margin-left: 50rpx;
		margin-top: 36rpx;
	}
</style>
